package com.ctv.my.customview.BaiajCustomView.activities;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.ctv.my.customview.BaiajCustomView.View.ThridBezier;
import com.ctv.my.customview.BaiajCustomView.adapters.BezierFragmentAdapter;
import com.ctv.my.customview.R;
import com.ctv.my.customview.BaiajCustomView.fragments.ThridBezierFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by baiaj on 2017/8/16.
 */

public class ThridBezierAct extends AppCompatActivity {

    private ViewPager mViewPager;
    private BezierFragmentAdapter mAdapter;
    private ThridBezier mBezier;
    private List<ThridBezierFragment> mFragments;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_thridbezier);
        initFragment();
        initView();
    }

    private void initFragment() {
        mFragments = new ArrayList<>();
        ThridBezierFragment fragment1 = new ThridBezierFragment();
        fragment1.setImageId(R.drawable.pos0);
        ThridBezierFragment fragment2 = new ThridBezierFragment();
        fragment2.setImageId(R.drawable.pos1);
        ThridBezierFragment fragment3 = new ThridBezierFragment();
        fragment3.setImageId(R.drawable.pos2);
        ThridBezierFragment fragment4 = new ThridBezierFragment();
        fragment4.setImageId(R.drawable.pos3);
        mFragments.add(fragment1);
        mFragments.add(fragment2);
        mFragments.add(fragment3);
        mFragments.add(fragment4);
    }

    private void initView() {
        mViewPager = (ViewPager) findViewById(R.id.third_bezier_viewpager);
        mBezier = (ThridBezier) findViewById(R.id.thrid_bezier);
        mAdapter = new BezierFragmentAdapter(getSupportFragmentManager(),mFragments);
        mViewPager.setAdapter(mAdapter);
        mBezier.setViewPager(mViewPager);
    }

}
